
/******************************************************************************\
|    Title:        	 TABLE E7: Regression Models for Becoming a Lobbyist -      |
						Switching staffers only								   |
|    Date:         	 July 2023	                                         	   |
|    Author:         Elisa Wirsching	      							       |
\******************************************************************************/


clear all
set more off, permanently
numlabel, add
set maxvar 32000

use congress_yearly.dta, clear
xtset stafferid year

* switchers only: define a subset who switch at least once during their time in Congress

bysort stafferid: egen switchsum = sum(switchtouncovered_treatment)
gen switcher = switchsum >=1

*******************************************
** 2008-2016

xtreg lobbydirectafter switchtouncovered_treatment i.year if posttreat==1 &  switcher==1, fe nonest vce(cluster stafferid) 
summarize lobbydirectafter if e(sample)==1
estadd scalar ymean = r(mean) 
est store model1
estadd local fixed "Yes" , replace
	
xtreg lobbydirectafter switchtouncovered_treatment daysworked committeestaff_everyear personalstaff_everyear senate_everyear majority_everyear minority_everyear ///
	dcoffice_everyear leaderofficestaff_everyear i.year if posttreat==1 & switcher==1, fe nonest cluster(stafferid)
summarize lobbydirectafter if e(sample)==1
estadd scalar ymean = r(mean) 
est store model2
estadd local fixed "Yes" , replace

xtreg lobbydirectafter switchtouncovered_treatment daysworked experience_imp experience_sq committeestaff_everyear personalstaff_everyear senate_everyear majority_everyear minority_everyear ///
	dcoffice_everyear leaderofficestaff_everyear i.year if posttreat==1 &  switcher==1, fe nonest cluster(stafferid)
summarize lobbydirectafter if e(sample)==1
estadd scalar ymean = r(mean) 
est store model3
estadd local fixed "Yes" , replace


*******************************************
** 2007-2016

xtreg lobbydirectafter switchtouncovered_treatment i.year if (posttreat==1 | year==2007) &  switcher==1, fe nonest vce(cluster stafferid) 
summarize lobbydirectafter if e(sample)==1
estadd scalar ymean = r(mean) 
est store model1b
estadd local fixed "Yes" , replace
	
xtreg lobbydirectafter switchtouncovered_treatment daysworked committeestaff_everyear personalstaff_everyear senate_everyear majority_everyear minority_everyear ///
	dcoffice_everyear leaderofficestaff_everyear i.year if (posttreat==1 | year==2007)  & switcher==1, fe nonest cluster(stafferid)
summarize lobbydirectafter if e(sample)==1
estadd scalar ymean = r(mean) 
est store model2b
estadd local fixed "Yes" , replace

xtreg lobbydirectafter switchtouncovered_treatment daysworked experience_imp experience_sq committeestaff_everyear personalstaff_everyear senate_everyear majority_everyear minority_everyear ///
	dcoffice_everyear leaderofficestaff_everyear i.year if (posttreat==1 | year==2007)  &  switcher==1, fe nonest cluster(stafferid)
summarize lobbydirectafter if e(sample)==1
estadd scalar ymean = r(mean) 
est store model3b
estadd local fixed "Yes" , replace


esttab model1 model2 model3 model1b model2b model3b using "TABLED7.csv", replace ///
	b(3) se(3) star(* .05 ** .01 *** 0.001) ///
	stats(fixed ymean N N_g r2, fmt(0 3 0 0 3) labels("Staffer FE" "Mean of DV"  "Observations" "Number of staffers" "R2"))  ///
	nomtitles mgroups("2008-2016" "2007-2016", pattern(1 0 0 1 0 0)) ///
	coeflabels(switchtouncovered_treatment "Switch to uncovered" daysworked "Days worked" experience_imp "Hill experience" experience_sq "Hill experience sq." committeestaff2_everyear "Committee staff" personalstaff_everyear "Personal staff" senate_everyear "Senate staff" majority_everyear "Majority party staff" minority_everyear "Minority party staff" dcoffice_everyear "DC office staff" leaderofficestaff_everyear "Leadership office staff") ///
    label parentheses nogaps nolines noeqlines ///
    noomitted nodepvars nobaselevels indicate("Year FE = *.year") nonotes noconstant
	


